let db = require('../db/index')

// 登录接口
const login = (req, res) => {
    let sql = 'select id,name,phone,imgUrl,username from user where username=? and password=?'
    db.query(sql, [req.body.username, req.body.password], (err, result) => {
        if (err) {
            return res.send({
                status: 400,
                message: '登录失败'
            })
        }
        if (result.length > 0) {
            res.send({
                status: 200,
                message: "登录成功",
                result: result[0]
            })
        }
        else {
            res.send({
                status: 202,
                message: '用户名或密码错误'
            })
        }
    })
}
module.exports = {
    login
}